# 文件大小转换
def format_size(size):
    kb = size / 1024
    mb = kb / 1024
    gb = mb / 1024
    if gb >= 1:
        return f"{gb:.2f} GB"
    elif mb >= 1:
        return f"{mb:.2f} MB"
    elif kb >= 1:
        return f"{kb:.2f} KB"
    else:
        return f"{size} Bytes"


# 判断是否是图片
def is_image(filename):
    image_extensions = ['.jpg', '.jpeg', '.png', '.bmp', '.jfif']  # 常见的图片文件格式扩展名
    file_extension = filename.split('.')[-1].lower()  # 获取文件扩展名并转换为小写
    if file_extension in image_extensions:
        return True
    else:
        return False
